<?php

namespace support;

use app\services\ConfigService;
use EasyWeChat\Factory;
use Webman\Config;

class EasyWechatFactory
{
    public static function getMiniProgramApp()
    {
        $config = ConfigService::getByGroup('wechat_miniprogram_pay');

        if (empty($config['mini_app_id']) || empty($config['mini_app_secret'])) {
            throw new \Exception('请先配置微信小程序支付参数');
        }

        $app = Factory::miniProgram($config);
        return $app;
    }
}